package com.joyzone.weixin.service;

import com.joyzone.weixin.exception.WeixinException;
import com.joyzone.weixin.user.UserInfo;
import com.joyzone.weixin.util.CommonUtil;
import com.joyzone.weixin.util.Constants;
import com.joyzone.weixin.util.StringUtil;

public class UserService {

	
	/**
	 * 拉取用户信息
	 * @param token 网页授权接口调用凭证
	 * @param openid 用户的唯一标识
	 * @return
	 * @throws WeixinException 
	 */
	public static UserInfo userinfo(String token, String openid) throws WeixinException {
		String url = StringUtil.formatParaUrl(Constants.Url_Oauth2_UserInfo,new String[]{token,openid} );
		return new UserInfo(CommonUtil.httpsRequest2Json(url, "GET", null)) ;
	}
}
